package first.endtoend

import first.endtoend.Aid

import java.text.DateFormat
import java.text.SimpleDateFormat

/*
this service is related to aid
 */

class AidService
{

    def categoryService

    def toJson(Aid aid)
    {


        DateFormat formatter;


        if (aid)
        {
            def dateStart = aid.startDate
            def dateEnd = aid.endDate
            def category = aid.category
            SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd')
            /* Formatter.DateTime myTimeZone=
             sdf.setTimeZone(TimeZone.getTimeZone(myTimeZone))
             println("###"+sdf.parse(dateStart))*/

            [
                    id          : aid.id,
                    aidStartDate: sdf.parse(dateStart.format('yyyy-MM-dd')),
                    aidEndDate  : sdf.parse(dateEnd.format('yyyy-MM-dd')),
                    aidCategory : categoryService.toJson(category)
            ]
        }
    }


}


